package com.nineclock.common.exception;

import com.nineclock.common.entity.Result;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.test.web.servlet.ResultHandler;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice
public class NcExceptionHandler {
    /*
    * 自定义异常(预料到的异常)
    * */

    @ExceptionHandler({ //指定 你要处理的异常
            NcException.class
    })
    public Result handlerCustomException(NcException e){
        e.printStackTrace();
        return Result.errorCodeMessage(e.getCode(),e.getMessage());
    }


    /*
    * 其他异常(没有预料的异常)
    * */
    @ExceptionHandler({
            Exception.class
    })
    public Result handlerOtherException(Exception e){
        e.printStackTrace();
        return Result.errorCodeMessage(500,"当前页面太过火爆请稍后重试!!!!");
    }
}
